package com.oocl.dao.base;

import java.util.List;




import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

@Repository("baseDao")
public class BaseDaoImpl extends BaseJPADaoUtil implements BaseDao {


	public Object persist(Object entity) {
		this.entityManager.persist(entity);
		return entity;
	}

	public Object update(Object entity) {
		System.out.println("111111");
		return this.entityManager.merge(entity);
	}

	public <T> void delete(Class<T> entityClass, Object entityId) {
		this.entityManager.remove(entityManager.getReference(entityClass,
				entityId));
	}

	public <T> Object find(Class<T> entityClass, Object entityId) {
		return this.entityManager.find(entityClass, entityId);
	}


	@SuppressWarnings("unchecked")
	public <T> List<T> findLists(Class<T> entityClass) {
		String jpql = "SELECT o FROM " + entityClass.getName() + " o ";
		return this.entityManager.createQuery(jpql).getResultList();
	}

}
